package com.zhanghaijun.createCode.util;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

public class PropsUtils {

	private static Properties settingProp  = null; 
	
	public static Properties getInstance(){
		if(settingProp==null){
			Resource resource = new ClassPathResource("/setting.properties");
			try {
				settingProp = PropertiesLoaderUtils.loadProperties(resource);
			} catch (IOException e) {
				e.printStackTrace();
			}
		} 
		
		return settingProp;
		
	}
	
	public static String getProp(String key){
		getInstance();
		if(settingProp!=null){
			return settingProp.getProperty(key);
		}
		return null;
	}
	
	
}
